/*
  S.M.A.C.K - An operating system kernel
  Copyright (C) 2010,2011 Mattias Holm and Kristian Rietveld
  For licensing and a full list of authors of the kernel, see the files
  COPYING and AUTHORS.
*/

#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <stdint.h>
#include <syscalls.h>

#include "gfx.h"


/* Animation */
static int fast_state = 0;
static int slow_state = 0;

static void
draw_dot_array(int x, int y, int state)
{
  gfx_fill_dot(x, y, 4, state > 0 ? 0xffff : 0x0000);
  gfx_fill_dot(x + 50, y, 4, state > 1 ? 0xffff : 0x0000);
  gfx_fill_dot(x + 100, y, 4, state > 2 ? 0xffff : 0x0000);
  gfx_fill_dot(x + 150, y, 4, state > 3 ? 0xffff : 0x0000);
}

int
main(int argc, char **argv)
{
  gfx_open();

  gfx_stroke_rect(50, 50, 700, 500, 0xffff);
  while (1)
    {
      draw_dot_array(325, 350, fast_state);
      draw_dot_array(325, 250, slow_state / 2);

      fast_state++;
      slow_state++;

      if (fast_state >= 5)
        fast_state = 0;
      if (slow_state >= 10)
        slow_state = 0;

      sleep(1);
    }

  gfx_close();
}
